﻿<UserControl x:Class="VSTalk.Engine.View.ContactEditorControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:model="clr-namespace:VSTalk.Model;assembly=VSTalk.Model">
    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0"
                       Grid.Row="0"
                       Text="Account" />
            <ComboBox Grid.Column="1"
                      Grid.Row="0"
                      Margin="2"
                      ItemsSource="{Binding Clients}"
                      SelectedItem="{Binding SelectedClient}">
                <ComboBox.Resources>
                    <DataTemplate DataType="{x:Type model:Client}">
                        <TextBlock Text="{Binding Login}" />
                    </DataTemplate>
                </ComboBox.Resources>
            </ComboBox>

            <TextBlock Grid.Column="0"
                       Grid.Row="1"
                       Text="Contact's username" />
            <TextBox Grid.Column="1"
                     Grid.Row="1"
                     Margin="2"
                     Text="{Binding Contact.Name, UpdateSourceTrigger=PropertyChanged}" />

            <TextBlock Grid.Column="0"
                       Grid.Row="2"
                       Text="Server" />
            <TextBox Grid.Column="1"
                     Grid.Row="2"
                     Margin="2"
                     Text="{Binding Contact.Server, UpdateSourceTrigger=PropertyChanged}" />

            <StackPanel Grid.Row="3"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Orientation="Horizontal"
                        HorizontalAlignment="Center">
                <Button Content="Add"
                        Command="{Binding SaveChanges}"
                        Margin="5" />
                <Button Content="Cancel"
                        Command="{Binding RejectChanges}"
                        Margin="5" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
